package net.aiform.template.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import net.aiform.pojo.Identity;
import net.aiform.security.pojo.FormAccessController;

@Entity
@Table(name = "af_template")
public class Template extends Identity implements Serializable {
	private static final long serialVersionUID = -5684761830352662130L;
	private String type;
	private Date recordStart;
	private Date recordEnd;
	private Date statisticsStart;
	private Date statisticsEnd;
	private int fieldsAmount;
	@OneToOne(targetEntity = FormAccessController.class)
	private FormAccessController recordAC;
	@OneToOne(targetEntity = FormAccessController.class)
	private FormAccessController resultAC;
	@OneToOne(targetEntity = FormAccessController.class)
	private FormAccessController statiticsAC;
	private String header;
	private String footer;
	private boolean random;
	private boolean recordUser;
	private boolean recordIp;
	private boolean recordTime;
	@OneToMany(mappedBy = "template", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private Set<Field> fields;

	public Set<Field> getFields() {
		return fields;
	}

	public int getFieldsAmount() {
		return fieldsAmount;
	}

	public String getFooter() {
		return footer;
	}

	public String getHeader() {
		return header;
	}

	public FormAccessController getRecordAC() {
		return recordAC;
	}

	public Date getRecordEnd() {
		return recordEnd;
	}

	public Date getRecordStart() {
		return recordStart;
	}

	public FormAccessController getResultAC() {
		return resultAC;
	}

	public Date getStatisticsEnd() {
		return statisticsEnd;
	}

	public Date getStatisticsStart() {
		return statisticsStart;
	}

	public FormAccessController getStatiticsAC() {
		return statiticsAC;
	}

	public String getType() {
		return type;
	}

	public boolean isRandom() {
		return random;
	}

	public boolean isRecordIp() {
		return recordIp;
	}

	public boolean isRecordTime() {
		return recordTime;
	}

	public boolean isRecordUser() {
		return recordUser;
	}

	public void setFields(Set<Field> fields) {
		this.fields = fields;
	}

	public void setFieldsAmount(int fieldsAmount) {
		this.fieldsAmount = fieldsAmount;
	}

	public void setFooter(String footer) {
		this.footer = footer;
	}

	public void setHeader(String header) {
		this.header = header;
	}

	public void setRandom(boolean random) {
		this.random = random;
	}

	public void setRecordAC(FormAccessController recordAC) {
		this.recordAC = recordAC;
	}

	public void setRecordEnd(Date recordEnd) {
		this.recordEnd = recordEnd;
	}

	public void setRecordIp(boolean recordIp) {
		this.recordIp = recordIp;
	}

	public void setRecordStart(Date recordStart) {
		this.recordStart = recordStart;
	}

	public void setRecordTime(boolean recordTime) {
		this.recordTime = recordTime;
	}

	public void setRecordUser(boolean recordUser) {
		this.recordUser = recordUser;
	}

	public void setResultAC(FormAccessController resultAC) {
		this.resultAC = resultAC;
	}

	public void setStatisticsEnd(Date statisticsEnd) {
		this.statisticsEnd = statisticsEnd;
	}

	public void setStatisticsStart(Date statisticsStart) {
		this.statisticsStart = statisticsStart;
	}

	public void setStatiticsAC(FormAccessController statiticsAC) {
		this.statiticsAC = statiticsAC;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String toString() {
		return "Template [fields=" + fields + ", fieldsAmount=" + fieldsAmount + ", footer=" + footer + ", header=" + header + ", random=" + random
				+ ", recordAC=" + recordAC + ", recordEnd=" + recordEnd + ", recordIp=" + recordIp + ", recordStart=" + recordStart + ", recordTime="
				+ recordTime + ", recordUser=" + recordUser + ", resultAC=" + resultAC + ", statisticsEnd=" + statisticsEnd + ", statisticsStart="
				+ statisticsStart + ", statiticsAC=" + statiticsAC + ", type=" + type + ", code=" + code + ", createTime=" + createTime
				+ ", expireTime=" + expireTime + ", id=" + id + ", name=" + name + "]";
	}

}
